package com.atwork.wuhua.mvp.model;

import com.atwork.wuhua.base.BaseEntity;
import com.atwork.wuhua.base.BaseModel;
import com.atwork.wuhua.base.BaseObserver;
import com.atwork.wuhua.bean.EvaluateBean;
import com.atwork.wuhua.bean.HomePageBean;
import com.atwork.wuhua.mvp.Callback;
import com.atwork.wuhua.utils.HttpUtil.RetrofitFactory;

import io.reactivex.disposables.Disposable;

public class LabelsModel extends BaseModel<EvaluateBean>{
    @Override
    public void execute(final Callback<EvaluateBean> callback) {
        RetrofitFactory.getInstence().API()
                .getLabels(mParams.getSecret())
                .compose(this.<BaseEntity<EvaluateBean>>setThread())
                .subscribe(new BaseObserver<EvaluateBean>() {
                    @Override
                    protected void onSuccees(BaseEntity<EvaluateBean> t) throws Exception {
                        if (t.isSuccess()) {
                            callback.onSuccess(t.getErrmsg(), t.getResult());
                        } else {
                            callback.onFailure(t.getErrmsg());
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {
                    }

                    @Override
                    protected void onRequestStart(Disposable disposable) {

                    }
                });
    }
}
